package cn.uyunsky.platform.config.loader;

import java.io.IOException;

import org.springframework.core.io.Resource;

import cn.uyunsky.platform.config.ConfigBeanInterface;
import cn.uyunsky.platform.config.ConfigLoader;
import cn.uyunsky.platform.jaxb.XmlConvert;
import cn.uyunsky.platform.jaxb.XmlConvertImpl;

/**
 * 通过对bean的配置;直接加载xml到bean
 * @author baiyh
 */
public class JAXBLoader implements ConfigLoader {

	private static XmlConvert convert = new XmlConvertImpl();

	@Override
	public ConfigBeanInterface loadConfig(Resource resource, Class<? extends ConfigBeanInterface> clazz)
			throws Exception {
		try {
			return convert.unpack(clazz, resource.getInputStream());
		} catch (IOException e) {
			throw e;
		}
	}

}
